home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 19 / Mac Magazin and MacEasy Magazine CD - Issue 19.iso / Musik & Kunst / Ear Workout 2.1 / source code / complete_window.h < prev    next >
Text File  |  1995-12-03  |  4KB  |  101 lines

  1. //
  2. //  This class includes everything I need to take care of the window.
  3. //  A window is to be read in from a DLOG resource, and the
  4. //  member "the_window" is actually the resulting DialogPtr,
  5. //  although in truth DialogPtr, WindowPtr, and GrafPtr are all
  6. //  synonyms.
  7. //  The data of the DLOG resource is assumed to be _non-recolcatable_,
  8. //  which is the case when you call GetNewDialog.
  9. //  The member "the_data" is a handle to whatever stuff needs to be stored
  10. //  for this window.  It's up to the den mother to decide how to use this,
  11. //  and whether it should be relocatable or locked.
  12. //  The creator calls GetNewDialog, which draws the window, so
  13. //  the den mother does not normally need to draw the window in
  14. //  response to the complete_window_created message, unless the
  15. //  resource indicates it is invisible.
  16. //  The creator automatically calls ParamText before drawing
  17. //  the window.
  18. //  When an update event is received, the program's main event loop
  19. //  should erase the contents of the window, call DrawControls,
  20. //  and then call the den mother with a "whassup" of complete_window_action.
  21.  
  22. enum complete_window_whassup {
  23.     complete_window_created ,    //-- lets den mother know we just created it,
  24.                     //      should initialize its data
  25.     complete_window_redraw ,    //-- tells den mother to redraw it
  26.     complete_window_action ,    //-- tells den mother to deal with an event
  27.     complete_window_erase         //-- tells den mother to get rid of
  28.                     //      its data, and/or save its data to disk
  29.                     //      because we're about to destroy it;
  30.                     //      destructor will erase it from the screen,
  31.                     //      den mother doesn't need to
  32. };
  33.  
  34. class complete_window;            // circular definition -- tell the compiler
  35.                     // I'll define this as a class later
  36. typedef void DEN_MOTHER_T(complete_window *);
  37.  
  38. class complete_window {
  39.   public:
  40.   
  41.   WindowPtr the_window;
  42.   int is_valid;
  43.   int resource_error;
  44.   int is_drawn;
  45.   int part_code;    //-- inCheckBox, etc.;  should be set by application's event 
  46.               //    loop before calling den mother (use FindControl)
  47.   int part_number;    //-- should be set by application's event (use FindDItem)
  48.               //    loop before calling den mother
  49.   complete_window_whassup whassup;
  50.   EventRecord *the_event;    //--for complete_window_action messages to the den mother
  51.   Str255 param_text0;     //--Pascal-style strings; see the toolbox routine ParamText
  52.   Str255 param_text1;
  53.   Str255 param_text2;
  54.   Str255 param_text3;
  55.   int has_den_mother;    //--set to 1 by creator of den mother is not null
  56.   DEN_MOTHER_T *den_mother;
  57.   void **data_handle;
  58.   void *data_pointer;
  59.   int data_int;
  60.   char *data_verb;
  61.   
  62.   complete_window::complete_window(
  63.             int dlog_resource_id,
  64.                 Str255 the_param_text0,
  65.                 Str255 the_param_text1,
  66.                 Str255 the_param_text2,
  67.                 Str255 the_param_text3,
  68.                 DEN_MOTHER_T *den_mother);
  69.   ~complete_window();
  70. };
  71.  
  72.  
  73.  
  74. void part_number_to_nifty_label(
  75.     char *nifty_name,
  76.     int *nifty_index,
  77.     char *decoder,
  78.     int part_num);
  79. int nifty_label_to_part_number(char *nifty_name,int nifty_index,char *decoder);
  80. int substring_to_integer(char *string,int first,int last);
  81. int find_char_in_string(char *the_string,int first,
  82.     int last,char the_char,int if_not_found);
  83. void get_rect_by_nifty_label(WindowPtr w,char *nifty_label,int nifty_index,
  84.             char *decoder_string,Rect *rr);
  85. void set_ctl_by_nifty_label(WindowPtr w,char *nifty_label,int nifty_index,
  86.             char *decoder_string,int value);            
  87. void hide_ctl_by_nifty_label(WindowPtr w,char *nifty_label,int nifty_index,
  88.             char *decoder_string);
  89. void show_ctl_by_nifty_label(WindowPtr w,char *nifty_label,int nifty_index,
  90.             char *decoder_string);
  91. void get_item_by_nifty_label(WindowPtr w,char *nifty_label,int nifty_index,
  92.             char *decoder_string,Handle *h);
  93. void refresh_text(complete_window *my_complete_window,
  94.             char *nifty_label,int nifty_index,char *decoder_string);
  95. void activate_ctl_by_nifty_label(WindowPtr w,char *nifty_label,int nifty_index,
  96.             char *decoder_string);
  97. void deactivate_ctl_by_nifty_label(WindowPtr w,char *nifty_label,int nifty_index,
  98.             char *decoder_string);
  99. void message_to_den_mother(complete_window *the_complete_window,void **data_h,
  100.             void *data_p,int data_i,char *data_v);
  101.